[r2r] lightning ordermatching wip + library updates and more unit tests#1655
[r2r] lightning ordermatching wip + library updates and more unit tests#1655
Conversation
…e chain, test is failing for now
…e not routes between swap parties
…check in lightning protocol info check
…bled and channel is closed before funding tx is confirmed
onur-ozkan
left a comment
There was a problem hiding this comment.
Amazing work! My notes from the partial review
| let expect_msg = "for the foreseeable future this shouldn't happen"; | ||
| let current_time: u32 = get_local_duration_since_epoch() | ||
| .expect(expect_msg) | ||
| .as_secs() | ||
| .try_into() | ||
| .expect(expect_msg); |
There was a problem hiding this comment.
| let expect_msg = "for the foreseeable future this shouldn't happen"; | |
| let current_time: u32 = get_local_duration_since_epoch() | |
| .expect(expect_msg) | |
| .as_secs() | |
| .try_into() | |
| .expect(expect_msg); | |
| let current_time: u32 = get_local_duration_since_epoch() | |
| .map_to_mm(|e| EnableLightningError::Internal(e.to_string()))? | |
| .as_secs() | |
| .try_into() | |
| .map_to_mm(|e| EnableLightningError::Internal(format!("{:?}", e)))?; |
| /// Get some of the coin config info in serialized format for p2p messaging. | ||
| fn coin_protocol_info(&self) -> Vec<u8>; | ||
| /// Get some of the coin protocol related info in serialized format for p2p messaging. | ||
| fn coin_protocol_info(&self, amount_to_receive: Option<MmNumber>) -> Vec<u8>; |
There was a problem hiding this comment.
Some of the implementations returning empty byte array, and this value is usually passed as Option type to the target. I am not sure if Some(Vec::new()) is handled properly. I would rather update the return type into Option<Vec<u8>> here and return None for functions that are returning Vec::new().
There was a problem hiding this comment.
@shamardy I think in most cases, an empty vec == None...what I'm saying it's unnecessary to use Option<Vec<_>> but instead just Vec<_>.
seems this is how optional keys field are mostly stored in structures mm2 so no problem ):
| [[package]] | ||
| name = "bech32" | ||
| version = "0.9.1" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445" |
There was a problem hiding this comment.
Only dependency that is still using 0.8.1 was KomodoPlatform/librustzcash, I upgraded bech32 to 0.9.1 there in k-1.0.0 tag. So we can avoid having 2 versions of bech32 that are almost identical.
You can apply the following patch for the version migration:
diff --git a/mm2src/coins/Cargo.toml b/mm2src/coins/Cargo.toml
index f35490716..1aa4824dc 100644
--- a/mm2src/coins/Cargo.toml
+++ b/mm2src/coins/Cargo.toml
@@ -125,10 +125,10 @@ tokio = { version = "1.7" }
tokio-rustls = { version = "0.23" }
tonic = { version = "0.7", features = ["tls", "tls-webpki-roots", "compression"] }
webpki-roots = { version = "0.22" }
-zcash_client_backend = { git = "https://github.com/KomodoPlatform/librustzcash.git" }
-zcash_client_sqlite = { git = "https://github.com/KomodoPlatform/librustzcash.git" }
-zcash_primitives = { features = ["transparent-inputs"], git = "https://github.com/KomodoPlatform/librustzcash.git" }
-zcash_proofs = { git = "https://github.com/KomodoPlatform/librustzcash.git" }
+zcash_client_backend = { git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.0.0" }
+zcash_client_sqlite = { git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.0.0" }
+zcash_primitives = { features = ["transparent-inputs"], git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.0.0" }
+zcash_proofs = { git = "https://github.com/KomodoPlatform/librustzcash.git", tag = "k-1.0.0" }
[target.'cfg(windows)'.dependencies]
winapi = "0.3"
There was a problem hiding this comment.
Thanks a lot for upgrading librustzcash. Patch applied.
caglaryucekaya
left a comment
There was a problem hiding this comment.
Great work! Some questions and comments
…ed due to a network error (all electrums were down, etc..)
|
I fixed 2 issues I discovered while executing a KMD/LNBTC swap, they were:
@caglaryucekaya @ozkanonur can you please review the new commits? |
onur-ozkan
left a comment
There was a problem hiding this comment.
@ozkanonur can you please review the new commits?
Both looks good to me
|
@caglaryucekaya can you please approve if there are no more issues with this PR? |
| if !e.get_inner().is_network_error() { | ||
| break; | ||
| } | ||
| Timer::sleep(TRY_LOOP_INTERVAL).await; |
There was a problem hiding this comment.
Should this loop repeat infinitely if the network error keeps coming?
There was a problem hiding this comment.
Yes for now. When broadcasting transaction through p2p network is implemented, a loop to check if the transaction is on-chain or not can be added instead.
| error!("Converting transaction to bytes error:{}", e); | ||
| break; | ||
| }, | ||
| }; |
There was a problem hiding this comment.
I think you can take this out of the loop, there's no need to repeat it in case of network failure
| pub enum SelectRecentSwapsUuidsErr { | ||
| Sql(SqlError), | ||
| Parse(uuid::parser::ParseError), | ||
| Parse(uuid::Error), |
There was a problem hiding this comment.
uuid::Error is used in multiple places already so it's better to import once
use uuid::Error as UuidError;and use everywhere
|
|
||
| impl From<uuid::parser::ParseError> for SelectRecentSwapsUuidsErr { | ||
| fn from(err: uuid::parser::ParseError) -> Self { SelectRecentSwapsUuidsErr::Parse(err) } | ||
| impl From<uuid::Error> for SelectRecentSwapsUuidsErr { |
borngraced
left a comment
There was a problem hiding this comment.
Great work! just a note and suggestion.
* add change logs for PRs merged to dev only
* remove {version} - {date} and add dev branch instead
* add ibc transfer change logs
* add lightning PR #1655 to change logs
* add changelog for #1706
* add changelog for #1694, #1665
---------
Reviewed-by: laruh, caglaryucekaya <caglaryucekaya@gmail.com>
Intermediate PR as part of #1045
current_confirmationsandrequired_confirmations(which are easy to retrieve after the above update) to channel details RPCs.uuidfor internal channel id instead ofu64after rust-lightning update since they now useu128foruser_channel_iduuidlib to latest version to use conversion from/tou128featuresprotocol_infofields are used to check if an order can be matched or not depending on if a route is found between maker/taker for a lightning payment.To be done in next PRs: